
#include "../Algorithms/graph_algos.h"
/*Dijkstra test*/
void p10986() {
    GRAPH g;
    int n, m, S, T, cases, k, i, u, v, w;
    int dist[20001], path[20001];

#ifndef ONLINE_JUDGE
    freopen("10986.in", "r", stdin);
#endif

    scanf("%d", &cases);

    k = 0;
    while (cases--) {
        k++;
        scanf("%d%d%d%d", &n, &m, &S, &T);
        graph_init(&g, n, m, undirected);
        for (i = 0; i < m; i++) {
            scanf("%d%d%d", &u, &v, &w);
            add_edge(&g, u + 1, v + 1, w);
        }

        dijkstra(&g, S + 1, dist, path);
        if (dist[T + 1] >= 1000010)
            printf("Case #%d: unreachable\n", k);
        else
            printf("Case #%d: %d\n", k, dist[T + 1]);
        graph_clean(&g);
    }
}
